package top.mccat.filesystem.resolver;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import top.mccat.filesystem.exception.AccountNotFoundException;
import top.mccat.filesystem.exception.TokenNotFoundException;
import top.mccat.filesystem.utils.AjaxResult;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 用于拦截token登录异常问题
 * @author Raven
 * @date 2023/02/25 11:58
 */
@ControllerAdvice
public class AccountExceptionResolver {
    @ResponseBody
    @ExceptionHandler({TokenNotFoundException.class})
    public AjaxResult handleTokenNotFoundException(TokenNotFoundException e){
        return AjaxResult.errorResult(e.getMessage(),e);
    }

    @ResponseBody
    @ExceptionHandler({AccountNotFoundException.class})
    public AjaxResult handleAccountNotFoundException( AccountNotFoundException e){
        return AjaxResult.errorResult(e.getMessage(),e);
    }
}
